home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Stella Obscura 1.1 / source / Parts ƒ / Sound.p < prev    next >
Encoding:
Text File  |  1988-04-09  |  3.4 KB  |  153 lines  |  [TEXT/PJMM]

  1. {
  2.   File: Sound.p
  3.  
  4.  Copyright Symantec Corporation 1988    
  5.  Copyright Apple Computer, Inc. 1986
  6.  All Rights Reserved
  7. }
  8.  
  9.  
  10.  
  11. UNIT Sound;
  12.  
  13. INTERFACE
  14.  
  15.     CONST
  16.  
  17.         {Command Numbers}
  18.         nullCmd            = 0;
  19.         initCmd            = 1;
  20.         freeCmd            = 2;
  21.         quietCmd        = 3;
  22.         flushCmd        = 4;
  23.         waitCmd            = 10;
  24.         pauseCmd        = 11;
  25.         resumeCmd        = 12;
  26.         callBackCmd        = 13;
  27.         syncCmd            = 14;
  28.         emptyCmd        = 15;
  29.         tickleCmd        = 20;
  30.         requestNextCmd    = 21;
  31.         howOftenCmd        = 22;
  32.         wakeUpCmd        = 23;
  33.         availableCmd    = 24;
  34.         noteCmd            = 40;
  35.         restCmd            = 41;
  36.         freqCmd            = 42;
  37.         ampCmd            = 43;
  38.         timbreCmd        = 44;
  39.         waveTableCmd    = 60;
  40.         phaseCmd        = 61;
  41.         soundCmd        = 80;
  42.         bufferCmd        = 81;
  43.         rateCmd            = 82;
  44.         midiDataCmd        = 100;
  45.         
  46.         { Constant for setting pointer bit of command number }
  47.         setPtrBit        = $8000;
  48.  
  49.         stdQLength        = 128;
  50.         stdQLengthMin1    = stdQLength - 1;
  51.  
  52.         {Error Returns}
  53.         noHardware            = -200;
  54.         notEnoughHardware    = -201;
  55.         queueFull            = -203;
  56.         resProblem            = -204;
  57.         badChannel            = -205;
  58.         badFormat            = -206;
  59.         
  60.         { Wave Table Synthesizer }
  61.         initChanLeft        = $02;    {left stereo channel}
  62.         initChanRight        = $03;    {right stereo channel}
  63.         initChan0            = $04;    {channel 0 - wave table only}
  64.         initChan1            = $05;    {channel 1 - wave table only}
  65.         initChan2            = $06;    {channel 2 - wave table only}
  66.         initChan3            = $07;    {channel 3 - wave table only}
  67.         initSRate22k        = $20;    {22k sampling rate}
  68.         initSRate44k        = $30;    {44k sampling rate}
  69.         initMono            = $80;    {monophonic channel}
  70.         initStereo            = $C0;    {stereo channel}
  71.  
  72.     TYPE
  73.         Time            = LONGINT;
  74.         
  75.         SndCommand        = PACKED RECORD
  76.                             cmd            : INTEGER;
  77.                             param1        : INTEGER;
  78.                             param2        : LONGINT;
  79.                           END;
  80.  
  81.         ModifierStub    = PACKED RECORD
  82.                             nextStub    : ^ModifierStub;
  83.                             code        : ProcPtr;
  84.                             userInfo    : LONGINT;
  85.                             count        : Time;
  86.                             every        : Time;
  87.                             flags        : SignedByte;
  88.                             hState        : SignedByte;
  89.                           END;
  90.         ModifierStubPtr    = ^ ModifierStub;
  91.         
  92.         SndChannel        = PACKED RECORD
  93.                             nextChan    : ^SndChannel;
  94.                             firstMod    : ^ModifierStub;
  95.                             callBack    : ProcPtr;
  96.                             userInfo    : Ptr;
  97.                             
  98.                             {The following is for internal Sound Manager use only.}
  99.                             wait            : Time;
  100.                             cmdInProgress    : SndCommand;
  101.                             flags            : INTEGER;
  102.                             qLength,
  103.                             qHead,
  104.                             qTail            : INTEGER;
  105.                             queue            : ARRAY [0..StdQLengthMin1] OF SndCommand;
  106.                           END;
  107.         SndChannelPtr    = ^ SndChannel;
  108.  
  109.  
  110.         SoundHeader        = RECORD
  111.                             samplePtr    : Ptr;    {if NIL then samples are in sampleArea}
  112.                             length        : LONGINT;
  113.                             sampleRate    : Fixed;
  114.                             loopStart,
  115.                             loopEnd        : LONGINT;
  116.                             baseNote    : INTEGER;
  117.                             {sampleArea    : PACKED ARRAY [0..0] OF Byte; -- not included, but logically here}
  118.                           END;
  119.         SoundHeaderPtr    = ^ SoundHeader;
  120.  
  121.  
  122.  
  123.     {Manager Routines}
  124.     
  125.     FUNCTION SndDoCommand(chan: SndChannelPtr; cmd: SndCommand; noWait: BOOLEAN): OSErr;
  126.         INLINE $A803;
  127.         
  128.     FUNCTION SndDoImmediate(chan: SndChannelPtr; cmd: SndCommand): OSErr;
  129.         INLINE $A804;
  130.         
  131.     FUNCTION SndAddModifier(chan: SndChannelPtr; modifier: ProcPtr; id: INTEGER;
  132.         init: LONGINT): OSErr;
  133.         INLINE $A802;
  134.         
  135.     FUNCTION SndNewChannel(VAR chan: SndChannelPtr; synth: INTEGER; init: LONGINT; 
  136.         userRoutine: ProcPtr): OSErr;
  137.         INLINE $A807;
  138.         
  139.     FUNCTION SndDisposeChannel(chan: SndChannelPtr; quietNow: BOOLEAN): OSErr;
  140.         INLINE $A801;
  141.         
  142.     FUNCTION SndPlay(chan: SndChannelPtr; sndHdl: Handle; async: BOOLEAN): OSErr;
  143.         INLINE $A805;
  144.         
  145.     FUNCTION SndControl(id: INTEGER; VAR cmd: SndCommand): OSErr;
  146.         INLINE $A806;
  147.  
  148. IMPLEMENTATION
  149. END.
  150.  
  151.  
  152.  
  153.